package com.h.heal.mapper;

import com.h.heal.entity.Comment;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface CommentMapper {
    @Select("SELECT * FROM `comment`")
    List<Comment> findAll();

    @Select("SELECT * FROM `comment` where comment_vid=#{comment_vid}")
    List<Comment> findByComment_vid(String comment_vid);

    @Select("SELECT * FROM `comment` where comment_uid=#{comment_uid}")
    List<Comment> findByComment_uid(String comment_uid);


    @Delete("delete from `comment` where comment_cid =#{comment_cid}")
    void deleteById(int id);


//    List<Topic> findBySearch(String topic_title, String topic_uid);


    @Insert("INSERT INTO `heal`.`comment` (`comment_cid`, `comment_uid`, `comment_vid`, `comment_maintext`, `comment_timestamp`,`comment_like`) VALUES (#{comment_cid}, #{comment_uid}, #{comment_vid}, #{comment_maintext},#{comment_timestamp},0)")
    void create(Comment comment);

    @Select("SELECT * FROM `comment` where comment_cid=#{comment_cid}")
    Comment findById(int id);


    List<Comment> findBySearch(@Param("comment_uid") String comment_uid, @Param("comment_vid") String comment_vid);


    int count(String comment_uid, String comment_vid);

    //分页查找
    List<Comment> findBySearchWithPage(String comment_uid, String comment_vid, int startPageIndex, int pageSize);

}
